package com.sky.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.sky.result.Result;
import com.sky.service.ShopService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ShopServiceImpl implements ShopService {
    public static final String KEY = "SHOP_STATUS";
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    /**
     * 获取状态
     * @return
     */
    @Override
    public Result<Integer> getStatus() {
        String status = stringRedisTemplate.opsForValue().get(KEY);
        log.info("获取营业状态");
        return Result.success(Integer.valueOf(status));
    }
    //修改营业状态
    @Override
    public Result updaStatys(Integer status) {
        log.info("修改营业状态：{}",status);
        stringRedisTemplate.opsForValue().set(KEY,status.toString());
        return Result.success();
    }
}
